"""
@name : 04.atm-面向对象
@author : wenyao
@projectname: xsfh
"""
#两类角色
#  ATM
#    属性 钱  银行（农大建设，农大农业）
#    方法
#        存钱
#        取钱
#        查看余额
class ATM:
    def __init__(self, money, bank):
        self.money = money
        self.bank = bank

    def add_money(self, money):
        print(f"添加金额：{money}")
        self.money += money

    def take_money(self, money):
        if money<= self.money:
            self.money -= money
            print(f"取出金额:{money}")
        else:
            print("余额不足")
#  用户
#  属性    用户名  密码  余额
#  方法
#      存钱
#      取钱
#      查询余额

class User:
    def __init__(self, name, passwd, balance):
        self.name = name
        self.passwd = passwd
        self.balance = balance

    def save_money(self, money, atmobj):
        print(f"存入金额:{money},在atm机:{atmobj.bank}")
        self.balance += money
        atmobj.money += money

    def get_money(self, money, atmobj):
        if self.balance >= money and atmobj.money >= money:
            self.balance -= money
            atmobj.money -= money
            print(f"取出金额：{money}")
        else:
            print("余额不足")

atm1 = ATM(50000,"农大建设银行")
atm2 = ATM(100000, "农大农业银行")
user1 = User("lzw","123456",50000)
atm1.add_money(20000)
print(atm1.money)
user1.get_money(40000,atm2)
print(user1.balance, atm2.money)